package com.lrs.java.j2se_self.lastJava;
import java.util.*;
public class EnhancedeFor {
	public static void main(String[] args){
		int[] a = {1,2,3,4,5};
		Collection c = new HashSet();
		c.add("a");
		c.add("b");
		c.add("d");
		for(int i : a){
			System.out.println(i);	
		}
		/*加强for循环
		for(Object s : c){
			System.out.println(s);
		}
		*/
		Collection c2 = new HashSet();
		c2.add("a");
		c2.add("b");
		c2.add("c");
		
		Collection cu = new HashSet(c);
		cu.addAll(c2);	
		Collection cn = new HashSet(c);
		cn.retainAll(c2);
		System.out.println("cn"+cn);
		System.out.println("cu"+cu);
		
		
		/* Iterator应用
		Iterator<String> i = c.iterator();
		while (i.hasNext()){
			String ss = i.next();
			if(ss.length()<4){
				i.remove();
			}
		}
		System.out.println(c);
		*/	
	}
}